Repository navigation
Graceful CUDA fallback for stub/broken CUDA libraries - #50
Merged
Merged
Conversation
On systems with stub CUDA libraries (e.g., incomplete driver installs), cudarc panics with missing symbol errors instead of returning errors. This causes colgrep and other tools to crash on startup. Changes: - Upgrade cudarc from 0.12 to 0.19.3 with dynamic-loading (dlopen) - Wrap all CUDA initialization paths in catch_unwind to trap panics - Add CUDA_BROKEN flag with clear_cuda_broken() to allow retrying after the user repairs their CUDA environment - Replace OnceLock<Option<CudaContext>> with OnceLock<Mutex<Option<Arc>>> so the cached context can be reset when clearing the broken flag - Protect ONNX Runtime CUDA provider init with catch_unwind - Use kmeans_double_chunked directly for CPU fallback in k-means to avoid FastKMeans::train() which re-enters CUDA when the feature is on - Add build.rs to detect CUDA toolkit at build time Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cudarc, ONNX Runtime CUDA EP,FastKMeansCuda) incatch_unwindto trap panics from stub/incomplete CUDA librariescudarcfrom 0.12 to 0.19.3 withdynamic-loading(dlopen at runtime instead of link-time)CUDA_BROKENflag withclear_cuda_broken()API so the cached state can be reset after the user repairs their CUDA environmentOnceLock<Option<CudaContext>>withOnceLock<Mutex<Option<Arc<CudaContext>>>>to support resettingkmeans_double_chunkeddirectly for CPU fallback to avoid re-entering CUDA viaFastKMeans::train()build.rsto detect CUDA toolkit at build timeContext
On systems with stub CUDA libraries (e.g., container images with
/usr/lib/x86_64-linux-gnu/libcuda.so.1but no real driver),cudarcpanics withundefined symbol: cuArray3DCreate_v2instead of returning an error. This crashed colgrep on startup.Depends on: lightonai/fastkmeans-rs#5
Test plan
cargo check --features cudacompilescargo check(no CUDA) compilesclear_cuda_broken()allows re-initialization after fixing CUDA🤖 Generated with Claude Code